package com.le.tester.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述：字符串中的单词数countSegments
 */
public class CountSegments {
    public int countSegments(String s) {
        if (0 == s.length()) {
            return 0;
        }
        String[] sSplit = s.split(" ");
        List<String> resultList = new ArrayList<>();
        for (String sItem : sSplit) {
            if (0 != sItem.length()) {
                resultList.add(sItem);
            }
        }
        return resultList.size();
    }

    public static void main(String[] args) {
        CountSegments countSegments = new CountSegments();
        System.out.println(countSegments.countSegments(", , , ,        a, eaefa"));
    }
}
